package com.carepad.action.menuitems;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import com.carepad.action.AbstractManagementAction;
import com.carepad.entity.RecordItemsGroup;
import com.carepad.exception.ItemNotFoundException;
import com.carepad.exception.NullReferenceAccessException;
import com.carepad.service.RecordItemsGroupService;

public abstract class AbstractRecordItemsGroupAction extends AbstractManagementAction {

	private static final long serialVersionUID = 1L;

	@Qualifier("recordItemsGroupService")
	@Autowired protected RecordItemsGroupService recordItemsGroupService;
	
	protected RecordItemsGroup recordItemsGroup;

	public RecordItemsGroup findById() {
		if(uid != null) {
			try{
				return recordItemsGroupService.findById(uid);
			}catch(Exception e) {
				throw new ItemNotFoundException("Id : " + uid);
			}
		} else {
			//logger
			throw new NullReferenceAccessException("Id cannot be null");
		}
	}

	public RecordItemsGroup getRecordItemsGroup() {
		return recordItemsGroup;
	}

	public void setRecordItemsGroup(RecordItemsGroup recordItemsGroup) {
		this.recordItemsGroup = recordItemsGroup;
	}
	
}
